<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    div {
      width: 500px;
      height: 500px;
      background: hotpink;
    }
  </style>
</head>
<body>
  <div></div>
  <script>
    // 获取事件源div
    var div = document.querySelector('div');
    // 注册鼠标进入事件
    div.onmouseenter = function() {
      console.log('鼠标进入了');
    };
    // 注册鼠标离开事件
    div.onmouseleave = function() {
      console.log('鼠标离开了');
    };

    // onmosueover 和 onmosueout
  </script>
</body>
</html>